package com.endava.exceptions.food_exception;

import java.util.logging.Level;
import java.util.logging.Logger;

public class MyException {

	private static void checkFood(String food) throws BadFoodException {

		String[] badFoods = { "soap", "lime", "coffee", "candy" };

		for (int i = 0; i < badFoods.length; i++) {
			if (!badFoods[i].equals(food)) {
				System.out.println("The bad food : " + badFoods[i]);
			} else {
				throw new BadFoodException(food);
			}
		}

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		String myFood = "soap";
		
		try {
			checkFood(myFood);
			System.out.println("\n\tYor food '" + myFood + "' is good !");
		} catch (BadFoodException e) {
			e.printStackTrace();
			Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, "'" + e.getMsg() + "' is bad food !");
		}

	}

}
